package com.css.fxfzxczh.modules.earthquakeLossRatio.controller;

import com.alibaba.fastjson.JSONObject;
import com.css.fxfzxczh.base.response.RestResponse;
import com.css.fxfzxczh.modules.earthquakeLossRatio.entity.EarthquakeLossRatio;
import com.css.fxfzxczh.modules.earthquakeLossRatio.service.EarthquakeLossRatioService;
import com.css.fxfzxczh.modules.earthquakeLossRatio.service.impl.EarthquakeLossRatioServiceImpl;
import com.css.fxfzxczh.modules.instrumentIntensity.entity.InstrumentIntensity;
import com.css.fxfzxczh.modules.instrumentIntensity.service.InstrumentIntensityService;
import com.css.fxfzxczh.modules.synthesizeInfoManage.earEveManage.entity.EarEveManage;
import com.css.fxfzxczh.modules.synthesizeInfoManage.vehManage.entity.VehManage;
import com.css.fxfzxczh.util.PlatformPageUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * @Author: xzy
 * @CreateTime: 2024/3/22 9:22
 * @Description: 仪器烈度
 */
@RestController
@RequestMapping("/earthquakeLossRatio")
@Slf4j
public class EarthquakeLossRatioController {

    @Resource
    EarthquakeLossRatioService earthquakeLossRatioService;




    @PostMapping("/save")
    public RestResponse save(@RequestBody EarthquakeLossRatio earthquakeLossRatio) {
        RestResponse response = null;
        JSONObject jsonObject = new JSONObject();
        try {
            earthquakeLossRatioService.save(earthquakeLossRatio);
            response = RestResponse.succeed();
            response.setMessage("保存成功");
        } catch (Exception e) {
            String errormessage = e.getMessage();
            log.error(errormessage,e);
            response=RestResponse.fail(errormessage);
        }
        return response;
    }

    @PostMapping("/update")
    public RestResponse update(@RequestBody EarthquakeLossRatio earthquakeLossRatio) {
        RestResponse response = null;
        JSONObject jsonObject = new JSONObject();
        try {
            earthquakeLossRatioService.update(earthquakeLossRatio);
            response = RestResponse.succeed();
            response.setMessage("修改成功");
        } catch (Exception e) {
            String errormessage = e.getMessage();
            log.error(errormessage,e);
            response=RestResponse.fail(errormessage);
        }
        return response;
    }


    /**
     * 查看
     *
     * @param id
     * @return
     */
    @GetMapping("/findById")
    public RestResponse findById(String xsemId) {
        RestResponse response = null;
        try {
            EarthquakeLossRatio earthquakeLossRatio=earthquakeLossRatioService.findById(xsemId);
            response = RestResponse.succeed(earthquakeLossRatio);
            response.setMessage("查看成功");
        } catch (Exception e) {
            String errorMessage = "查看失败!";
            log.error(errorMessage, e);
            response = RestResponse.fail(errorMessage);
        }
        return response;
    }





}
